namespace ShellNavigator.Client.Models
{
  #region

  using System.Collections.Generic;
  using System.Linq;

  using ShellNavigator.Client.Core;

  #endregion

  public class ProjectInfo : InfoBase
  {
    #region Constants and Fields

    public ProjectInfo(FileInfo file)
    {
      Files = new[] { new FileInfo(file, this) };
    }

    public ProjectInfo(IEnumerable<FileInfo> files)
    {
      this.Files = files.Select(file => new FileInfo(file, this));
    }

    public ProjectInfo(ProjectInfo origin, SolutionInfo parent)
    {
      this.Name = origin.Name;
      this.Files = origin.Files.Select(file => new FileInfo(file, this));
      this.ParentSolution = parent;
    }

    #endregion

    #region Public Properties

    public IEnumerable<FileInfo> Files { get; private set; }

    public string Name { get; set; }

    public SolutionInfo ParentSolution { get; private set; }

    #endregion

    public override void RunAction(AppActions action)
    {
      switch (action)
      {
        case AppActions.OpenSolution:
          ShellExecutor.OpenStudio(this.ParentSolution.Name, this.Files.Select(x => x.Name));
          break;
        case AppActions.OpenProject:
          ShellExecutor.OpenStudio(this.Name, this.Files.Select(x => x.Name));
          break;
        case AppActions.OpenFile:
          ShellExecutor.OpenShell(this.Name);
          break;
        case AppActions.CopyFile:
          ShellExecutor.CopyToClipboard(this.Files.Select(x => x.Name));
          break;
        case AppActions.CopyProject:
          ShellExecutor.CopyToClipboard(this.Name);
          break;
        case AppActions.CopyAssembly:
          ShellExecutor.CopyAssemblyName(this.Name);
          break;
        case AppActions.CopySolution:
          ShellExecutor.CopyToClipboard(this.ParentSolution.Name);
          break;
      }
    }
  }
}